home *** CD-ROM | disk | FTP | other *** search
- #include <math.h>
- #include "matrix.hxx"
- #include "Cheb_vector.hxx"
- #include "vimatrix.hxx"
- #undef TEST
- /*
- -*++ vi_matrix::vi_matrix(): initializer for vorticity inversion matrix
- **
- ** (*++ history:
- ** 11 Dec 87 Bruce Eckel Creation date
- ** ++*)
- **
- ** (*++ detailed: create an n x n matrix and initialize it as the vorticity
- ** inversion matrix.
- ** ++*)
- */
-
- vi_matrix::vi_matrix(int n, double lambda) : (n,n,0)
- {
- for (int row = 0; row < size()-2; row++){
- for (int col = row+2; col < size(); col++) {
- if ( (row+col)%2 == 0 )
- (*this)[row][col] = (col/C(row))*(col*col - row*row);
- }
- (*this)[row][row] = -lambda;
- }
- double flip = -1.0;
- for( int col = 0; col < size(); col++){
- (*this)[size()-2][col] = flip;
- (*this)[size()-1][col] = 1;
- flip = -flip;
- }
- /* else element = 0, which is the initialized value */
- }
-
-
-
- /*
- -*++ vi_matrix::operator*(): vi_matrix * chebyshev vector
- **
- ** (*++ history:
- ** 16 Jan 88 Bruce & Creation date
- ** ++*)
- **
- ** (*++ detailed:
- ** ++*)
- */
-
- Cheb_vector & vi_matrix::operator*(Cheb_vector & C)
- {
- if (cols() != C.size() || cols() != rows())
- error("matrix must be square and dimension of Cheb_vect for *!");
- Cheb_vector & result = *new Cheb_vector(C.size());
- for(int row = 0; row < rows(); row++) {
- double sum = 0;
- for(int i = 0; i < cols(); i++) {
- /* cout << "row = " << row << " i = " << i << "\n";
- cout.flush();
- cout << "(*this)[row][i] = " << (*this)[row][i] << "\n";
- cout.flush();
- cout << "C[i] = " << C[i] << "\n";
- cout.flush();
- cout << "((*this)[row][i])) * (C[i]) = "
- << ((*this)[row][i]) * (C[i]) <<"\n";
- cout.flush();
- */
- double temp1 = ((*this)[row][i]);
- double temp2 = (C[i]);
- /* sum += ((*this)[row][i]) * (C[i]); */
- sum += temp1 * temp2;
- /* cout << "sum = " << sum << "\n";
- cout.flush();
- */
- }
- result[row] = sum;
- /* cout << "result[row] = " << result[row] << "\n\n";
- cout.flush();
- */
- }
- return result;
- }
-
- #ifdef TEST
- main(int argc, char **argv) {
- vi_matrix H(atoi(argv[1]), atof(argv[2]));
- cout << H << NL;
- }
- #endif